package com.dks.controller.student;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.dks.dto.BaseIdRequestDto;
import com.dks.dto.student.AppointClassDto;
import com.dks.dto.student.PositionWaitDto;
import com.dks.exception.BaseException;
import com.dks.models.student.AppointmentClassStrategy;
import com.dks.repository.IAppointmentClassRepository;
import com.dks.result.*;
import com.dks.util.PageInfo;

/**
 * 约课等位相关
 */
@RestController
@RequestMapping("appointment-class")
public class AppointmentClassController {

    @Autowired
    private IAppointmentClassRepository appointmentClassRespository;

    /**
     * 约课攻略-列表
     * @author evan
     */
    @GetMapping("strategy/list")
    public ResultModel<PageInfo<AppointmentClassStrategy>> getStrategyList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                          @RequestParam(value = "pageSize",defaultValue = "15") Integer pageSize){
        return appointmentClassRespository.getStrategyList(pageNum, pageSize);
    }

    /**
     * 约课攻略-详情
     * @author evan
     */
    @GetMapping("strategy/{id}")
    public ResultModel<AppointmentClassStrategy> getStrategy(@PathVariable("id") Integer id){
        if (id == null){
            return Result.makeResultAppend(ResultInfo.ERR_BASE_001, "id");
        }
        return appointmentClassRespository.getStrategy(id);
    }

    /**
     * 固定位-约课
     * @author evan
     */
    @PostMapping("fixed")
    public ResultModel<Boolean> fixed(@RequestBody @Validated AppointClassDto appointClassDto) throws BaseException {
        return appointmentClassRespository.fixed(appointClassDto);
    }

    /**
     * 临时位-约课
     * @author evan
     */
    @PostMapping("temporary")
    public ResultModel<Boolean> temporary(@RequestBody @Validated AppointClassDto appointClassDto) throws BaseException {
        return appointmentClassRespository.temporary(appointClassDto);
    }

//    /**
//     * 体验位-约课
//     * @author evan
//     */
//    @PostMapping("experience")
//    public ResultModel<Boolean> experience(@RequestBody @Validated AppointClassDto appointClassDto){
//        return appointmentClassRespository.experience(appointClassDto);
//    }

    /**
     * 固定位-等位
     * @author evan
     */
    @PostMapping("fixed/wait")
    public ResultModel<Boolean> fiexedWait(@RequestBody @Validated PositionWaitDto positionWaitDto) throws BaseException {
        return appointmentClassRespository.fixedWait(positionWaitDto);
    }

    /**
     * 固定位-取消等位
     * @param baseIdRequestDto id 排位表id
     * @author evan
     */
    @PostMapping("fixed/wait/cancel")
    public ResultModel<Boolean> fiexedWaitCancel(@RequestBody @Validated BaseIdRequestDto baseIdRequestDto) throws BaseException {
        return appointmentClassRespository.fiexedWaitCancel(baseIdRequestDto);
    }


}
